<?php

/*

Process Update Profile (update_profile.pro.php)

*/
ob_start();
include "global.inc.php";

$check_username = strtolower(ereg_replace(" ", "", $update_display_name));
if ($check_username == $username)
{
	mysql_query("UPDATE members2 SET display_name = '$update_display_name' WHERE username = '$username' AND game = '$game'") or die ("Database error: ".mysql_error());
}

if (($update_mybirthmonth >= 1) AND ($update_mybirthmonth <= 12) AND ($update_mybirthday >= 1) AND ($update_mybirthday <= 31) AND ($update_mybirthyear >= 0) AND ($update_mybirthyear <= $this_year))
{
	$birthday = "$update_mybirthmonth-$update_mybirthday-$update_mybirthyear";
	mysql_query("UPDATE members_profiles2 SET birthday = '$birthday' WHERE username = '$username' AND game = '$game'") or die ("Database error: ".mysql_error());
}

if (($update_my_gender >= 1) OR ($update_my_gender <= 2))
{
	mysql_query("UPDATE members_profiles2 SET gender = '$update_my_gender' WHERE username = '$username' AND game = '$game'") or die ("Database error: ".mysql_error());
}

if (($update_mailsettings >= 0) OR ($update_mailsettings <= 2))
{
	mysql_query("UPDATE members_profiles2 SET mail_settings = '$update_mailsettings' WHERE username = '$username' AND game = '$game'") or die ("Database error: ".mysql_error());
}

if ((!$update_location) OR (!$update_myemail) OR (!$update_myname))
{
	die(header(error("update_profile.php?game=$game","BOLD RED fields must not be blank!")));
}

$profile = smilies(badwords(strip_tags($update_myprofile,"<b><i><u><a><font><img><p><br>")));
$signature = badwords(strip_tags($update_signature,"<b><i><u><a><font>"));
$update_myemail = badwords(strip_tags($update_myemail,""));
$update_myname = badwords(strip_tags($update_myname,"<b><i><u>"));
$update_location = badwords(strip_tags($update_location,""));

mysql_query("UPDATE members_profiles2 SET location = '$update_location' WHERE username = '$username' AND game = '$game'");
mysql_query("UPDATE members_profiles2 SET profile = '$profile' WHERE username = '$username' AND game = '$game'");
mysql_query("UPDATE members_profiles2 SET signature = '$signature' WHERE username = '$username' AND game = '$game'");
mysql_query("UPDATE members_profiles2 SET real_name = '$update_myname' WHERE username = '$username' AND game = '$game'");
mysql_query("UPDATE members_profiles2 SET email = '$update_myemail' WHERE username = '$username' AND game = '$game'");

die(header(error("update_profile.php?game=$game","Your information has been updated successfully!")));

?>